﻿<%@ page contentType="text/html;charset=UTF-8"
	import="org.yoao.crm.struts.form.MenuForm" pageEncoding="UTF-8"%>
<%
	String url = request.getRequestURI();
	String base = url.substring(1);
	base = base.substring(0, base.indexOf("/"));
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	MenuForm menuForm = (MenuForm) request.getAttribute("MenuForm");
	if (menuForm == null)
		menuForm = new MenuForm();
	String headImage = menuForm.getHeadImage();
	if (menuForm.getHeadImage() == null
			|| menuForm.getHeadImage().trim().equals("")
			|| menuForm.getHeadImage().equals("null"))
		menuForm.setHeadImage(basePath
				+ "images/treeIcon/defaultIcon.gif");
	String message = (String) request.getAttribute("Message");
	String oimgName = menuForm.getHeadImage().replaceFirst(
			basePath + "images/treeIcon/", "").replaceAll(".gif", "");
%>
<Html>
	<head>
		<base href="<%=basePath%>">
		<title>新建页签</title>
		<meta Http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<jsp:include page="../public/publicJs.jsp" flush="false"></jsp:include>
		<script language="javaScript">
var imgSrc = "<%=menuForm.getHeadImage()%>";//供选图片的路径
var oldImgName = "<%=oimgName%>";
function fn_formCheck() {
	locking();
	document.getElementById("myLoad").innerHTML = "<img src='<%=basePath%>images/loading.gif' alt='数据保存中' class='icon1' border='0' align='absmiddle'/> 数据保存中,请稍后......";
	return true;
}
function showUrl(value) {
	if (value == "MarkForm") {
		document.getElementById("tr_url").style.display = "none";
		document.getElementById("viewTypeShow").innerText = "标签";
	} else if (value == "ViewForm") {
		document.getElementById("tr_url").style.display = "block";
		document.getElementById("viewTypeShow").innerText = "视图";
	}
}
function locking() {
	document.all.ly.style.display = "block";
	document.all.ly.style.width = document.body.clientWidth;
	document.all.ly.style.height = document.body.clientHeight;
	document.all.Layer2.style.display = "block";
	return true;
}
function unLock() {
	document.all.ly.style.display = "none";
	document.all.Layer2.style.display = "none";
	return false;
}
function openRole(type) {
	var access = window.showModalDialog(
			"<%=basePath%>kmjsp/dialog/datawindow.jsp", "角色选择",
			"dialogWidth=390px;dialogHeight=300px");
	if ("CANCELROLE" == access)
		return;
	var sname = "";
	var ssno = "";
	if (access) {
		var barray = access.split(";");
		if (barray != null) {
			for ( var i = 0; i < barray.length; i++) {
				var sarray = barray[i].split("|");
				if (sarray != null) {
					sname += sarray[1] + ";";
					ssno += sarray[0] + ";";
				} else {
					sname = barray;
					ssno = barray;
				}
			}
		} else {
			sname = barray;
			ssno = barray;
		}
	}

	if (ssno.lastIndexOf(";") == ssno.length - 1)
		ssno = ssno.substring(0, ssno.length - 1);
	if (sname.lastIndexOf(";") == sname.length - 1)
		sname = sname.substring(0, sname.length - 1);
	if ("ADD" == type
			&& (document.all.accessSno.value != null && document.all.accessSno.value != "")) {
		document.all.accessSno.value = document.all.accessSno.value + ";"
				+ ssno;
		document.all.accessName.value = document.all.accessName.value + ";"
				+ sname;
	} else {
		document.all.accessSno.value = ssno;
		document.all.accessName.value = sname;
	}
}
</script>
	</head>
	<body topmargin="0" leftmargin="0" class="dialog"
		onLoad="public_onload();">
		<form name="markform" action="menu.crm?method=save" method="post">
			<input type="hidden" name="sortNumber"
				value="<%=menuForm.getSortNumber()%>" />
			<input type="hidden" name="isActive"
				value="<%=menuForm.getIsActive()%>" />
			<input type="hidden" name="layer" value="<%=menuForm.getLayer()%>" />

			<table class="title_top" width=100% height=100% align=center
				cellspacing=0 border="0" cellpadding="0">
				<tr valign="top">
					<td align=center width=100% height=100%>
						<table align=center width=96% border="0" cellspacing="0"
							cellpadding="0" style="margin-top: 12px">
							<tr valign="top">
								<td width="100%">
									<table border="0" cellspacing="0" cellpadding="0">
										<tr valign="top">
											<td id="Form_tab_0" class="Form_tab" width=80 align=center
												valign="middle" height="20">
												页签
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr valign="top">
								<td class="tab_subline" width="100%"></td>
							</tr>
						</table>
						<center>
							<div class="tabBody">
								<table width=98% align=center width="100%" border="0"
									cellspacing="0" cellpadding="0" class="maintab_content_table">

									<tr valign="top" style="display: none">
										<td class="Form_BBS_Lable" width=160 width="14%"
											valign="middle">
											&nbsp;&nbsp;唯一码
										</td>
										<td class="Form_BBS_td" width="86%" valign="middle">
											<input class="text_220" name="keyName" readonly
												value="<%=menuForm.getKeyName() != null ? menuForm.getKeyName()
					: ""%>" />
										</td>
									</tr>

									<tr valign="top">
										<td width=160 width="14%" valign="middle">
											&nbsp;&nbsp;
											<font color="#FF0000">*</font>&nbsp;名 称
										</td>
										<td width="86%" valign="middle">
											<input class="text_220" style="width: 250px" name="title"
												value="<%=menuForm.getTitle() != null ? menuForm.getTitle() : ""%>" />
										</td>
									</tr>

									<tr valign="top">
										<td width=160 width="14%" valign="middle">
											&nbsp;&nbsp;
											<font color="#FF0000">*</font>&nbsp;类型
										</td>
										<td width="86%" valign="middle">
											<input type="radio" name="formType" value="MarkForm"
												onClick="showUrl(this.value)"
												<%if ("MarkForm".equals(menuForm.getFormType())) {%> checked
												<%}%>>
											页签
											<input type="radio" name="formType" value="ViewForm"
												onClick="showUrl(this.value)"
												<%if ("ViewForm".equals(menuForm.getFormType())) {%> checked
												<%}%>>
											视图
										</td>
									</tr>

									<tr valign="top">
										<td width=160 width="14%" valign="middle">
											&nbsp;&nbsp;
											<font color="#FF0000">*</font>&nbsp;显示图标
										</td>
										<td width="86%" valign="middle">
											<div id="imgBox" style="width: 20px; height: 45px"></div>
											<input id="headImage" name="headImage" type="hidden"
												size="10"
												value="<%=menuForm.getHeadImage() != null ? menuForm.getHeadImage()
					: ""%>">
										</td>
									</tr>

									<tr id="tr_url" valign="top" style="display: none">
										<td width=160 width="14%" valign="middle">
											&nbsp;&nbsp;
											<font color="#FF0000">*</font>&nbsp;链接地址
										</td>
										<td width="86%" valign="middle">
											<input class="text_220" style="width: 250px" name="url"
												value="<%=menuForm.getUrl() != null ? menuForm.getUrl() : ""%>" />
										</td>
									</tr>

									<tr>
										<td class="Form_BBS_Lable" width="13%" nowrap valign="middle">
											&nbsp;&nbsp;创建日期
										</td>
										<td class="Form_BBS_td" width="87%" valign="middle">
											<input class="text_220" style="width: 250px"
												name="createTime" readonly
												value="<%=menuForm.getCreateTime() != null ? menuForm
					.getCreateTime() : ""%>" />
										</td>
									</tr>

									<tr valign="top">
										<td width="14%" valign="middle">
											&nbsp;&nbsp;描 述
										</td>
										<td width="86%" valign="middle">
											<textarea class="text_multi" style="width: 80%; height: 60px"
												cols="20" rows="5" name="memo"><%=menuForm.getMemo() != null ? menuForm.getMemo() : ""%></textarea>
										</td>
									</tr>

									<tr>
										<td class="Form_BBS_Lable" width="13%" nowrap valign="middle">
											&nbsp;访问者
										</td>
										<td class="Form_BBS_td" width="87%" valign="middle" nowrap>
											<table width="100%" align="center" border="0" cellspacing="0"
												cellpadding="0">
												<tr>
													<td rowspan="2"
														style="border: solid 0px white border-bottom : 0; width: 81%">
														<textArea name="accessName" readonly
															style="width: 100%; height: 100px"><%=menuForm.getAccessName() != null ? menuForm
					.getAccessName() : ""%></textArea>
														<textArea name="accessSno" style="display: none"><%=menuForm.getAccessSno() != null ? menuForm.getAccessSno()
					: ""%></textArea>
													</td>
													<td style="border: solid 0px white border-bottom : 0;"
														align="left">
														<img src="<%=basePath%>images/btn_seluser.gif"
															class="icon1" align="absmiddle" alt="添加角色"
															style="cursor: pointer" onClick="openRole('ADD');">
													</td>
												</tr>
												<tr>
													<td style="border: solid 0px white border-bottom : 0;"
														align="left">
														<img src="<%=basePath%>images/icon_role.gif" class="icon1"
															align="absmiddle" alt="选择角色" style="cursor: pointer"
															onClick="openRole();">
													</td>
												</tr>
											</table>
									</td>
									</tr>
								</table>
							</div>
						</center>
						</br>
						</br>
						<table width=96% align=center border="0" cellspacing="0"
							cellpadding="0" style="margin-top: -6px">
							<tr>
								<td style="padding: 3px" width="10%">
									菜单:
									<span id="viewTypeShow"><%=menuForm.getFormType().equals("MarkForm") ? "页签" : "视图"%></span>
								</td>
								<td width="65%" valign="middle">
									<div id="myLoad" style="text-align: left"></div>
								</td>
								<td width="25%" valign="middle"><jsp:include
										page="./sform/btn_formsave.jsp" flush="true"></jsp:include></td>
							</tr>
						</table>
						<%
							if (message != null && message.trim().length() > 0) {
						%>
						<script type="text/javascript">
document.getElementById("myLoad").innerHTML = "<img src='<%=basePath%>images/info.gif' alt='数据保存信息' class='icon1' border='0' align='absmiddle'/> <%=message%>";
</script>
						<%
							}
						%>
					</td>
				</tr>
			</table>
		</form>
		<div id="ly"
			style="position: absolute; top: 0px; filter: alpha(opacity = 60); background-color: #777; z-index: 2; left: 0px; display: none"></div>
		<div id="Layer2" align="center"
			style="display: none; background: #fff; width: 160px; height: 20px; left: 40%; top: 40%; position: absolute; padding: 5px 5px 5px 5px; z-index: 3; filter: alpha(opacity = 60);">
			<font color="#FF0000" style="font-size: 12px"><img
					src="<%=basePath%>images/loading.gif" alt="数据同步中" class="icon1"
					border="0" align="absmiddle" /> 数据保存中,请稍后...</font>
		</div>
		<SCRIPT Language="Javascript" SRC="<%=basePath%>js/selectImg.js"></SCRIPT>
		<script language="javascript">
ShowTabN(0);
showUrl("<%=menuForm.getFormType()%>");
unLock();
</script>
	</body>
</Html>